package org.sy.lab.多线程基础._1_管理._3_守护线程;

import java.util.concurrent.TimeUnit;

/**
 * 守护线程会在所有线程结束后结束
 */
public class Main {

	public static void main(String[] args) {
		
		Thread daemonThread = new Thread(new DaemonThread());
		daemonThread.setDaemon(true);
		daemonThread.start();
		
		Thread myThread = new Thread(new MyThread());
		myThread.start();
		
		try {
			//等待线程结束
			myThread.join();
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		
		try {
			TimeUnit.SECONDS.sleep(5);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("主线程便当");
	}
}
